//
//  ChartDataView.m
//  iMoc
//
//  Created by 微我网络 on 15/1/20.
//  Copyright (c) 2015年 lamcelot. All rights reserved.
//

#import "ChartDataView.h"
#import "CustomChartView.h"

@interface ChartDataView ()

@property (nonatomic,strong) UILabel *label0;
@property (nonatomic,strong) UILabel *label1;
@property (nonatomic,strong) UILabel *label2;
@property (nonatomic,strong) UILabel *label3;
@property (nonatomic,strong) UILabel *label4;
@property (nonatomic,strong) UILabel *label5;

@property (nonatomic,strong) UILabel *value0;
@property (nonatomic,strong) UILabel *value1;
@property (nonatomic,strong) UILabel *value2;
@property (nonatomic,strong) UILabel *value3;
@property (nonatomic,strong) UILabel *value4;
@property (nonatomic,strong) UILabel *value5;

@property (nonatomic,strong) NSArray *type0Label;
@property (nonatomic,strong) NSArray *type1Label;
@property (nonatomic,strong) NSArray *type2Label;

@property (nonatomic,strong) NSArray *type3Label;
@property (nonatomic,strong) NSArray *type4Label;
@property (nonatomic,strong) NSArray *type5Label;

@property (nonatomic) UIImageView *departLine;

@end

@implementation ChartDataView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        _type0Label = @[@"热量消耗",@"步行距离",@"运动目标"];
        _type1Label = @[@"日均步数",@"日均里程",@"日均消耗",@"完成目标",@"周总里程",@"周总消耗"];
        _type2Label = @[@"日均步数",@"日均里程",@"日均消耗",@"完成目标",@"月总里程",@"月总消耗"];
        
        _type3Label = @[@"深睡时长",@"浅睡时长",@"活动时长",@"入睡时间",@"醒来时间"];
        _type4Label = @[@"日均睡眠",@"大于8时",@"小于8时"];
        _type5Label = @[@"日均睡眠",@"大于8时",@"小于8时"];
        
        int labelSize = 12;
        
        _label0 = [[UILabel alloc] init];
        _label0.frame = CGRectMake(0, 0, frame.size.width/3, 20);
//        _label0.text = _type0Label[0];
        _label0.textAlignment = NSTextAlignmentCenter;
        _label0.textColor = [UIColor lightGrayColor];
        _label0.font = [UIFont systemFontOfSize:labelSize];
        [self addSubview:_label0];
        
        _label1 = [[UILabel alloc] init];
        _label1.frame = CGRectMake(frame.size.width/3, 0, frame.size.width/3, 20);
//        _label1.text = _type0Label[1];
        _label1.textAlignment = NSTextAlignmentCenter;
        _label1.textColor = [UIColor lightGrayColor];
        _label1.font = [UIFont systemFontOfSize:labelSize];
        [self addSubview:_label1];
        
        _label2 = [[UILabel alloc] init];
        _label2.frame = CGRectMake(frame.size.width/3*2, 0, frame.size.width/3, 20);
//        _label2.text = _type0Label[2];
        _label2.textAlignment = NSTextAlignmentCenter;
        _label2.textColor = [UIColor lightGrayColor];
        _label2.font = [UIFont systemFontOfSize:labelSize];
        [self addSubview:_label2];
        
        _label3 = [[UILabel alloc] init];
        _label3.frame = CGRectMake(0, 76, frame.size.width/3, 20);
//        _label3.text = _type0Label[3];
        _label3.textAlignment = NSTextAlignmentCenter;
        _label3.textColor = [UIColor lightGrayColor];
        _label3.font = [UIFont systemFontOfSize:labelSize];
        [self addSubview:_label3];
        
        _label4 = [[UILabel alloc] init];
        _label4.frame = CGRectMake(frame.size.width/3, 76, frame.size.width/3, 20);
//        _label4.text = _type0Label[4];
        _label4.textAlignment = NSTextAlignmentCenter;
        _label4.textColor = [UIColor lightGrayColor];
        _label4.font = [UIFont systemFontOfSize:labelSize];
        [self addSubview:_label4];
        
        _label5 = [[UILabel alloc] init];
        _label5.frame = CGRectMake(frame.size.width/3*2, 76, frame.size.width/3, 20);
//        _label5.text = _type0Label[5];
        _label5.textAlignment = NSTextAlignmentCenter;
        _label5.textColor = [UIColor lightGrayColor];
        _label5.font = [UIFont systemFontOfSize:labelSize];
        [self addSubview:_label5];
        
        for (int i = 0; i < 4; i++) {
            UIImageView *depart = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"departLine0"]];
            depart.frame = CGRectMake(frame.size.width/3*(1+i%2), 10+76*(i/2), 0.5, 28);
            depart.tag = 200+i;
            [self addSubview:depart];
        }
        
        /**
         velues
         
         :returns: parameter key-
         */
        int valueSize = 15;
        
        _value0 = [[UILabel alloc] init];
        _value0.frame = CGRectMake(0, 20, frame.size.width/3, 30);
        _value0.textAlignment = NSTextAlignmentCenter;
        _value0.textColor = [UIColor whiteColor];
        _value0.font = [UIFont systemFontOfSize:valueSize];
        [self addSubview:_value0];
        
        _value1 = [[UILabel alloc] init];
        _value1.frame = CGRectMake(frame.size.width/3, 20, frame.size.width/3, 30);
        _value1.textAlignment = NSTextAlignmentCenter;
        _value1.textColor = [UIColor whiteColor];
        _value1.font = [UIFont systemFontOfSize:valueSize];
        [self addSubview:_value1];
        
        _value2 = [[UILabel alloc] init];
        _value2.frame = CGRectMake(frame.size.width/3*2, 20, frame.size.width/3, 30);
        _value2.textAlignment = NSTextAlignmentCenter;
        _value2.textColor = [UIColor whiteColor];
        _value2.font = [UIFont systemFontOfSize:valueSize];
        [self addSubview:_value2];
        
        _value3 = [[UILabel alloc] init];
        _value3.frame = CGRectMake(0, 96, frame.size.width/3, 30);
        _value3.textAlignment = NSTextAlignmentCenter;
        _value3.textColor = [UIColor whiteColor];
        _value3.font = [UIFont boldSystemFontOfSize:17];
        [self addSubview:_value3];
        
        _value4 = [[UILabel alloc] init];
        _value4.frame = CGRectMake(frame.size.width/3, 96, frame.size.width/3, 30);
        _value4.textAlignment = NSTextAlignmentCenter;
        _value4.textColor = [UIColor whiteColor];
        _value4.font = [UIFont boldSystemFontOfSize:17];
        [self addSubview:_value4];
        
        _value5 = [[UILabel alloc] init];
        _value5.frame = CGRectMake(frame.size.width/3*2, 96, frame.size.width/3, 30);
        _value5.textAlignment = NSTextAlignmentCenter;
        _value5.textColor = [UIColor whiteColor];
        _value5.font = [UIFont systemFontOfSize:valueSize];
        [self addSubview:_value5];
        
        [self setString0:@"0"];
        [self setString1:@"0"];
        [self setString2:@"0"];
        [self setString3:@"0"];
        [self setString4:@"0"];
        [self setString5:@"0"];
        
        _departLine = [[UIImageView alloc]initWithFrame:CGRectMake(20, frame.size.height/2-20, self.frame.size.width-40, 3)];
        [self addSubview:_departLine];
        
        UIGraphicsBeginImageContext(_departLine.frame.size);
        [_departLine.image drawInRect:CGRectMake(0, 0, _departLine.frame.size.width, _departLine.frame.size.height)];
        CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
        CGFloat lengths[] = {4,2};
        CGContextRef line = UIGraphicsGetCurrentContext();
        CGContextSetStrokeColorWithColor(line, [UIColor colorWithRed:190/255.f green:140/255.f blue:130/255.f alpha:0.7].CGColor);
        CGContextSetLineDash(line, 0, lengths, 2);
        CGContextMoveToPoint(line, 0.0, 1);
        CGContextAddLineToPoint(line, 320, 1);
        CGContextStrokePath(line);
        _departLine.image = UIGraphicsGetImageFromCurrentImageContext();
        
    }
    return self;
}

//_type0Label = @[@"热量消耗",@"步行距离",@"运动目标"];
//_type1Label = @[@"日均步数",@"日均里程",@"日均消耗",@"完成目标",@"周总里程",@"周总消耗"];
//_type2Label = @[@"日均步数",@"日均里程",@"日均消耗",@"完成目标",@"月总里程",@"月总消耗"];
//
//_type3Label = @[@"深睡时长",@"浅睡时长",@"活动时长",@"入睡时间",@"醒来时间"];
//_type4Label = @[@"日均睡眠",@"大于8时",@"小于8时"];
//_type5Label = @[@"日均睡眠",@"大于8时",@"小于8时"];

- (void)setStyle:(ChartDataViewStyle)style {
    
    NSLog(@"%ld",style);
    _style = style;
    
    switch (style) {
        case 0:
            _label0.text = _type0Label[0];
            _label1.text = _type0Label[1];
            _label2.text = _type0Label[2];
//            _label3.text = _type0Label[3];
//            _label4.text = _type0Label[4];
//            _label5.text = _type0Label[5];
            
            _label0.hidden = NO;
            _label1.hidden = NO;
            _label2.hidden = NO;
            _label3.hidden = YES;
            _label4.hidden = YES;
            _label5.hidden = YES;
            _departLine.hidden = YES;
            _value0.hidden = NO;
            _value1.hidden = NO;
            _value2.hidden = NO;
            _value3.hidden = YES;
            _value4.hidden = YES;
            _value5.hidden = YES;
            
            ((UIImageView *)[self viewWithTag:200]).hidden = NO;
            ((UIImageView *)[self viewWithTag:201]).hidden = NO;
            ((UIImageView *)[self viewWithTag:202]).hidden = YES;
            ((UIImageView *)[self viewWithTag:203]).hidden = YES;
            break;
            
        case 1:
            _label0.text = _type1Label[0];
            _label1.text = _type1Label[1];
            _label2.text = _type1Label[2];
            _label3.text = _type1Label[3];
            _label4.text = _type1Label[4];
            _label5.text = _type1Label[5];
            
            _label0.hidden = NO;
            _label1.hidden = NO;
            _label2.hidden = NO;
            _label3.hidden = NO;
            _label4.hidden = NO;
            _label5.hidden = NO;
            _departLine.hidden = NO;
            _value0.hidden = NO;
            _value1.hidden = NO;
            _value2.hidden = NO;
            _value3.hidden = NO;
            _value4.hidden = NO;
            _value5.hidden = NO;
            
            ((UIImageView *)[self viewWithTag:200]).hidden = NO;
            ((UIImageView *)[self viewWithTag:201]).hidden = NO;
            ((UIImageView *)[self viewWithTag:202]).hidden = NO;
            ((UIImageView *)[self viewWithTag:203]).hidden = NO;
            break;
            
        case 2:
            _label0.text = _type2Label[0];
            _label1.text = _type2Label[1];
            _label2.text = _type2Label[2];
            _label3.text = _type2Label[3];
            _label4.text = _type2Label[4];
            _label5.text = _type2Label[5];
            
            
            _label0.hidden = NO;
            _label1.hidden = NO;
            _label2.hidden = NO;
            _label3.hidden = NO;
            _label4.hidden = NO;
            _label5.hidden = NO;
            _departLine.hidden = NO;
            _value0.hidden = NO;
            _value1.hidden = NO;
            _value2.hidden = NO;
            _value3.hidden = NO;
            _value4.hidden = NO;
            _value5.hidden = NO;
            
            ((UIImageView *)[self viewWithTag:200]).hidden = NO;
            ((UIImageView *)[self viewWithTag:201]).hidden = NO;
            ((UIImageView *)[self viewWithTag:202]).hidden = NO;
            ((UIImageView *)[self viewWithTag:203]).hidden = NO;
            break;
            
        case 3:
            _label0.text = _type3Label[0];
            _label1.text = _type3Label[1];
            _label2.text = _type3Label[2];
            _label3.text = _type3Label[3];
            _label4.text = _type3Label[4];
//            _label5.text = _type3Label[5];
            
            _label0.hidden = NO;
            _label1.hidden = NO;
            _label2.hidden = NO;
            _label3.hidden = NO;
            _label4.hidden = NO;
            _label5.hidden = YES;
            _departLine.hidden = NO;
            _value0.hidden = NO;
            _value1.hidden = NO;
            _value2.hidden = NO;
            _value3.hidden = NO;
            _value4.hidden = NO;
            _value5.hidden = YES;
            
            ((UIImageView *)[self viewWithTag:200]).hidden = NO;
            ((UIImageView *)[self viewWithTag:201]).hidden = NO;
            ((UIImageView *)[self viewWithTag:202]).hidden = NO;
            ((UIImageView *)[self viewWithTag:203]).hidden = YES;
            break;
            
        case 4:
            _label0.text = _type4Label[0];
            _label1.text = _type4Label[1];
            _label2.text = _type4Label[2];
//            _label3.text = _type4Label[3];
//            _label4.text = _type4Label[4];
//            _label5.text = _type3Label[5];
            
            _label0.hidden = NO;
            _label1.hidden = NO;
            _label2.hidden = NO;
            _label3.hidden = YES;
            _label4.hidden = YES;
            _label5.hidden = YES;
            _departLine.hidden = YES;
            _value0.hidden = NO;
            _value1.hidden = NO;
            _value2.hidden = NO;
            _value3.hidden = YES;
            _value4.hidden = YES;
            _value5.hidden = YES;
            
            ((UIImageView *)[self viewWithTag:200]).hidden = NO;
            ((UIImageView *)[self viewWithTag:201]).hidden = NO;
            ((UIImageView *)[self viewWithTag:202]).hidden = YES;
            ((UIImageView *)[self viewWithTag:203]).hidden = YES;
            break;
            
        case 5:
            _label0.text = _type5Label[0];
            _label1.text = _type5Label[1];
            _label2.text = _type5Label[2];
//            _label3.text = _type3Label[3];
//            _label4.text = _type3Label[4];
//            _label5.text = _type3Label[5];
            
            _label0.hidden = NO;
            _label1.hidden = NO;
            _label2.hidden = NO;
            _label3.hidden = YES;
            _label4.hidden = YES;
            _label5.hidden = YES;
            _departLine.hidden = YES;
            _value0.hidden = NO;
            _value1.hidden = NO;
            _value2.hidden = NO;
            _value3.hidden = YES;
            _value4.hidden = YES;
            _value5.hidden = YES;
            
            ((UIImageView *)[self viewWithTag:200]).hidden = NO;
            ((UIImageView *)[self viewWithTag:201]).hidden = NO;
            ((UIImageView *)[self viewWithTag:202]).hidden = YES;
            ((UIImageView *)[self viewWithTag:203]).hidden = YES;
            break;
            
        default:
            break;
    }
    
    [self setString0:@"0"];
    [self setString1:@"0"];
    [self setString2:@"0"];
    [self setString3:@"0"];
    [self setString4:@"0"];
    [self setString5:@"0"];
    
    switch (_style) {
//        case 0:break;
//        case 1:
//        case 2:break;
        case 3: {
            [self setString3:@"00:00"];
            [self setString4:@"00:00"];
        }break;
//        case 4:
//        case 5:
//            break;
        default:
            break;
    }
}

- (void)setString0:(NSString *)string {
    
    if (!string) {
        return;
    }
    
    switch (_style) {
        case 0: {
            _string0 = [string stringByAppendingString:@"千卡"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string0];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string0.length-2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string0.length-2, 2)];
            _value0.attributedText = attribute;
        }break;
        case 1:
        case 2: {
            _string0 = [string stringByAppendingString:@"步"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string0];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string0.length-1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string0.length-1, 1)];
            _value0.attributedText = attribute;
        }break;
            
        case 3:
        case 4:
        case 5: {
            _string0 = [NSString stringWithFormat:@"%02ld时%02ld分",[string integerValue]/60,[string integerValue]%60];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string0];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0,2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(2, 1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(3, 2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(5, 1)];
            _value0.attributedText = attribute;
        }break;
            
        default:
            break;
    }
}

- (void)setString1:(NSString *)string {
    if (!string) {
        return;
    }
    switch (_style) {
        case 0:
        case 1:
        case 2: {
            _string1 = [string stringByAppendingString:@"千米"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string1];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string1.length-2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string1.length-2, 2)];
            _value1.attributedText = attribute;
        }break;
            
        case 3: {
            _string1 = [NSString stringWithFormat:@"%02ld时%02ld分",[string integerValue]/60,[string integerValue]%60];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string1];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0,2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(2, 1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(3, 2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(5, 1)];
            _value1.attributedText = attribute;
        }break;
        case 4:
        case 5: {
            _string1 = [string stringByAppendingString:@"天"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string1];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string1.length-1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string1.length-1, 1)];
            _value1.attributedText = attribute;
        }break;
            
        default:
            break;
    }
}

- (void)setString2:(NSString *)string {
    if (!string) {
        return;
    }
    switch (_style) {
        case 0: {
            _string2 = [string stringByAppendingString:@"步"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string2];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string2.length-1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string2.length-1, 1)];
            _value2.attributedText = attribute;
        }break;
            
        case 1:
        case 2: {
            _string2 = [string stringByAppendingString:@"千卡"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string2];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string2.length-2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string2.length-2, 2)];
            _value2.attributedText = attribute;
        }break;
            
        case 3: {
            _string2 = [NSString stringWithFormat:@"%02ld时%02ld分",[string integerValue]/60,[string integerValue]%60];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string2];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0,2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(2, 1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(3, 2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(5, 1)];
            _value2.attributedText = attribute;
        }break;
        case 4:
        case 5: {
            _string2 = [string stringByAppendingString:@"天"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string2];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string2.length-1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string2.length-1, 1)];
            _value2.attributedText = attribute;
        }break;
            
        default:
            break;
    }
}

- (void)setString3:(NSString *)string {
    if (!string) {
        string = @"00:00";
        
    }
    switch (_style) {
        case 0:break;
        case 1:
        case 2: {
            _string3 = [string stringByAppendingString:@"天"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string3];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string3.length-1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string3.length-1, 1)];
            _value3.attributedText = attribute;
        }break;
            
        case 3: {
            _string3 = string;
            _value3.text = _string3;
        }break;
        case 4:
        case 5: {
            
            _string3 = [string stringByAppendingString:@"天"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string3];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string3.length-1)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string3.length-1, 1)];
            _value3.attributedText = attribute;
        }break;
        default:
            break;
    }
}

- (void)setString4:(NSString *)string {
    if (!string) {
        string = @"00:00";
    }
    switch (_style) {
        case 0:break;
        case 1:
        case 2: {
            _string4 = [string stringByAppendingString:@"千米"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string4];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string4.length-2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string4.length-2, 2)];
            _value4.attributedText = attribute;
        }break;
        case 3: {
            _string4 = string;
            _value4.text = _string4;
        }break;
        case 4:
        case 5: {
            _string4 = [string stringByAppendingString:@"千米"];
            NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string4];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string4.length-2)];
            [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                                       NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string4.length-2, 2)];
            _value4.attributedText = attribute;
        }break;
        default:
            break;
    }
}

- (void)setString5:(NSString *)string {
    if (!string) {
        return;
    }
    _string5 = [string stringByAppendingString:@"千卡"];
    NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:_string5];
    [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                               NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, _string5.length-2)];
    [attribute addAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:9],
                               NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(_string5.length-2, 2)];
    _value5.attributedText = attribute;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
